<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NumCpp: gauss_legendre.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="NumCppLogoDoxygen.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">NumCpp
   &#160;<span id="projectnumber">2.1.0</span>
   </div>
   <div id="projectbrief">A C++ implementation of the Python Numpy library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('gauss__legendre_8hpp_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">gauss_legendre.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="gauss__legendre_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_constants_8hpp.html">NumCpp/Core/Constants.hpp</a>&quot;</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_types_8hpp.html">NumCpp/Core/Types.hpp</a>&quot;</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="sqr_8hpp.html">NumCpp/Utils/sqr.hpp</a>&quot;</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160; </div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#include &lt;cmath&gt;</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="preprocessor">#include &lt;functional&gt;</span></div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacenc.html">nc</a></div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;{</div>
<div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="namespacenc_1_1integrate.html">   45</a></span>&#160;    <span class="keyword">namespace </span>integrate</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;    {</div>
<div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;        <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;        <span class="comment">// Class Description:</span></div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html">   51</a></span>&#160;<span class="comment"></span>        <span class="keyword">class </span><a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html">LegendrePolynomial</a></div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;        {</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;        <span class="keyword">public</span>:</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;            <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;            <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00060"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a2e1fefae138e66215cd7586a85fc3642">   60</a></span>&#160;<span class="comment"></span>            <span class="keyword">explicit</span> <a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html#a2e1fefae138e66215cd7586a85fc3642">LegendrePolynomial</a>(<span class="keyword">const</span> <a class="code" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> numIterations) noexcept :</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                numIterations_(numIterations),</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;                weight_(numIterations + 1),</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;                root_(numIterations + 1)</div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;            {</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;                calculateWeightAndRoot();</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;            }</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;            <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;            <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac6b804e8a2d582df601cc2b3ff2bf74f">   74</a></span>&#160;<span class="comment"></span>            <span class="keyword">const</span> std::vector&lt;double&gt;&amp; <a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac6b804e8a2d582df601cc2b3ff2bf74f">getWeight</a>() const noexcept </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;            {</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;                <span class="keywordflow">return</span> weight_;</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;            }</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160; </div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;            <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;            <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="line" href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac2d8f6377f8ae7cf27b4d0599eb7880b">   85</a></span>&#160;<span class="comment"></span>            <span class="keyword">const</span> std::vector&lt;double&gt;&amp; <a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac2d8f6377f8ae7cf27b4d0599eb7880b">getRoot</a>() const noexcept </div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;            {</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;                <span class="keywordflow">return</span> root_;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;            }</div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160; </div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;        <span class="keyword">private</span>:</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;            <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;            <span class="comment">// Class Description:</span></div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;<span class="comment"></span>            <span class="keyword">struct </span>Result</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;            {</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;                <span class="keywordtype">double</span> value{ 0.0 };</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;                <span class="keywordtype">double</span> derivative{ 0.0 };</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160; </div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;                <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;                <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;<span class="comment"></span>                Result(<span class="keyword">const</span> <span class="keywordtype">double</span> val, <span class="keyword">const</span> <span class="keywordtype">double</span> deriv) noexcept :</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;                    value(val),</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;                    derivative(deriv)</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;                {}</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;            };</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160; </div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;            <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;            <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;<span class="comment"></span>            <span class="keywordtype">void</span> calculateWeightAndRoot() noexcept</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;            {</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;                <span class="keyword">const</span> <span class="keyword">auto</span> numIterationsDouble = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(numIterations_);</div>
<div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;                <span class="keywordflow">for</span> (<a class="code" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> step = 0; step &lt;= numIterations_; ++step)</div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;                {</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;                    <span class="keywordtype">double</span> root = <a class="code" href="namespacenc.html#a736de91eb8f79bfaf4dc92d7161f1c87">std::cos</a>(<a class="code" href="namespacenc_1_1constants.html#a2f1219a120c9cc1434486d9de75a8221">constants::pi</a> * (<span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(step) - 0.25) / (numIterationsDouble + 0.5));</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;                    Result result = calculatePolynomialValueAndDerivative(root);</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160; </div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;                    <span class="keywordtype">double</span> newtonRaphsonRatio;</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;                    <span class="keywordflow">do</span></div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;                    {</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;                        newtonRaphsonRatio = result.value / result.derivative;</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;                        root -= newtonRaphsonRatio;</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;                        result = calculatePolynomialValueAndDerivative(root);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;                    } <span class="keywordflow">while</span> (std::fabs(newtonRaphsonRatio) &gt; EPSILON);</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160; </div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;                    root_[step] = root;</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;                    weight_[step] = 2.0 / ((1.0 - <a class="code" href="namespacenc_1_1utils.html#ae792e10a24b7e5b8291a6c31a28a4512">utils::sqr</a>(root)) * result.derivative * result.derivative);</div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;                }</div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;            }</div>
<div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160; </div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;            <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;            <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;<span class="comment"></span>            Result calculatePolynomialValueAndDerivative(<span class="keyword">const</span> <span class="keywordtype">double</span> x) noexcept</div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;            {</div>
<div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;                Result result(x, 0.0);</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160; </div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;                <span class="keywordtype">double</span> value_minus_1 = 1.0;</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;                <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="namespacenc_1_1random.html#a00229c23da25284daf436c0a338ea25c">f</a> = 1.0 / (<a class="code" href="namespacenc_1_1utils.html#ae792e10a24b7e5b8291a6c31a28a4512">utils::sqr</a>(x) - 1.0);</div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;                <span class="keywordflow">for</span> (<a class="code" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> step = 2; step &lt;= numIterations_; ++step)</div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;                {</div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;                    <span class="keyword">const</span> <span class="keyword">auto</span> stepDouble = <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(step);</div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;                    <span class="keyword">const</span> <span class="keywordtype">double</span> value = ((2.0 * stepDouble - 1.0) * x * result.value - (stepDouble - 1.0) * value_minus_1) / stepDouble;</div>
<div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;                    result.derivative = stepDouble * <a class="code" href="namespacenc_1_1random.html#a00229c23da25284daf436c0a338ea25c">f</a> * (x * value - result.value);</div>
<div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160; </div>
<div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;                    value_minus_1 = result.value;</div>
<div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;                    result.value = value;</div>
<div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;                }</div>
<div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160; </div>
<div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;                <span class="keywordflow">return</span> result;</div>
<div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;            }</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160; </div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;            <span class="comment">//===================================Attributes==============================</span></div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;            <span class="keyword">const</span> <span class="keywordtype">double</span> EPSILON{ 1<a class="code" href="namespacenc_1_1constants.html#aebabe96d6c2be3df3d71922b399e24c7">e</a>-15 };</div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160; </div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;            <span class="keyword">const</span> <a class="code" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a>        numIterations_;</div>
<div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;            std::vector&lt;double&gt; weight_;</div>
<div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;            std::vector&lt;double&gt; root_;</div>
<div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;        };</div>
<div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160; </div>
<div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        <span class="comment">//============================================================================</span></div>
<div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;        <span class="comment">// Method Description:</span></div>
<div class="line"><a name="l00183"></a><span class="lineno"><a class="line" href="namespacenc_1_1integrate.html#af7d17b4e025bf94f903d3c671da3baf7">  183</a></span>&#160;<span class="comment"></span>        <span class="keyword">inline</span> <span class="keywordtype">double</span> <a class="code" href="namespacenc_1_1integrate.html#af7d17b4e025bf94f903d3c671da3baf7">gauss_legendre</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> low, <span class="keyword">const</span> <span class="keywordtype">double</span> high, <span class="keyword">const</span> <a class="code" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> n,</div>
<div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;            <span class="keyword">const</span> std::function&lt;<span class="keywordtype">double</span>(<span class="keywordtype">double</span>)&gt;&amp; <a class="code" href="namespacenc_1_1random.html#a00229c23da25284daf436c0a338ea25c">f</a>)</div>
<div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;        {</div>
<div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;            <span class="keyword">const</span> <a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html">LegendrePolynomial</a> legendrePolynomial(n);</div>
<div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;            <span class="keyword">const</span> std::vector&lt;double&gt;&amp; weight = legendrePolynomial.<a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac6b804e8a2d582df601cc2b3ff2bf74f">getWeight</a>();</div>
<div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;            <span class="keyword">const</span> std::vector&lt;double&gt;&amp; root = legendrePolynomial.<a class="code" href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac2d8f6377f8ae7cf27b4d0599eb7880b">getRoot</a>();</div>
<div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160; </div>
<div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;            <span class="keyword">const</span> <span class="keywordtype">double</span> width = 0.5 * (high - low);</div>
<div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;            <span class="keyword">const</span> <span class="keywordtype">double</span> <a class="code" href="namespacenc.html#ae215351046b49fec834d006fd35a4078">mean</a> = 0.5 * (low + high);</div>
<div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160; </div>
<div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;            <span class="keywordtype">double</span> gaussLegendre = 0.0;</div>
<div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;            <span class="keywordflow">for</span> (<a class="code" href="namespacenc.html#af0f49663fb63332596e2e6327009d581">uint32</a> step = 1; step &lt;= n; ++step)</div>
<div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;            {</div>
<div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;                gaussLegendre += weight[step] * <a class="code" href="namespacenc_1_1random.html#a00229c23da25284daf436c0a338ea25c">f</a>(width * root[step] + <a class="code" href="namespacenc.html#ae215351046b49fec834d006fd35a4078">mean</a>);</div>
<div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;            }</div>
<div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160; </div>
<div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;            <span class="keywordflow">return</span> gaussLegendre * width;</div>
<div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;        }</div>
<div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    }  <span class="comment">// namespace integrate</span></div>
<div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;}  <span class="comment">// namespace nc</span></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<div class="ttc" id="anamespacenc_1_1integrate_html_af7d17b4e025bf94f903d3c671da3baf7"><div class="ttname"><a href="namespacenc_1_1integrate.html#af7d17b4e025bf94f903d3c671da3baf7">nc::integrate::gauss_legendre</a></div><div class="ttdeci">double gauss_legendre(const double low, const double high, const uint32 n, const std::function&lt; double(double)&gt; &amp;f)</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:183</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html_ac6b804e8a2d582df601cc2b3ff2bf74f"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac6b804e8a2d582df601cc2b3ff2bf74f">nc::integrate::LegendrePolynomial::getWeight</a></div><div class="ttdeci">const std::vector&lt; double &gt; &amp; getWeight() const noexcept</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:74</div></div>
<div class="ttc" id="a_constants_8hpp_html"><div class="ttname"><a href="_constants_8hpp.html">Constants.hpp</a></div></div>
<div class="ttc" id="anamespacenc_html_ae215351046b49fec834d006fd35a4078"><div class="ttname"><a href="namespacenc.html#ae215351046b49fec834d006fd35a4078">nc::mean</a></div><div class="ttdeci">NdArray&lt; double &gt; mean(const NdArray&lt; dtype &gt; &amp;inArray, Axis inAxis=Axis::NONE)</div><div class="ttdef"><b>Definition:</b> mean.hpp:54</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html_a2e1fefae138e66215cd7586a85fc3642"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html#a2e1fefae138e66215cd7586a85fc3642">nc::integrate::LegendrePolynomial::LegendrePolynomial</a></div><div class="ttdeci">LegendrePolynomial(const uint32 numIterations) noexcept</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:60</div></div>
<div class="ttc" id="anamespacenc_html_a736de91eb8f79bfaf4dc92d7161f1c87"><div class="ttname"><a href="namespacenc.html#a736de91eb8f79bfaf4dc92d7161f1c87">nc::cos</a></div><div class="ttdeci">auto cos(dtype inValue) noexcept</div><div class="ttdef"><b>Definition:</b> cos.hpp:52</div></div>
<div class="ttc" id="anamespacenc_1_1constants_html_aebabe96d6c2be3df3d71922b399e24c7"><div class="ttname"><a href="namespacenc_1_1constants.html#aebabe96d6c2be3df3d71922b399e24c7">nc::constants::e</a></div><div class="ttdeci">constexpr double e</div><div class="ttdoc">eulers number</div><div class="ttdef"><b>Definition:</b> Constants.hpp:42</div></div>
<div class="ttc" id="anamespacenc_html_af0f49663fb63332596e2e6327009d581"><div class="ttname"><a href="namespacenc.html#af0f49663fb63332596e2e6327009d581">nc::uint32</a></div><div class="ttdeci">std::uint32_t uint32</div><div class="ttdef"><b>Definition:</b> Types.hpp:41</div></div>
<div class="ttc" id="anamespacenc_1_1constants_html_a2f1219a120c9cc1434486d9de75a8221"><div class="ttname"><a href="namespacenc_1_1constants.html#a2f1219a120c9cc1434486d9de75a8221">nc::constants::pi</a></div><div class="ttdeci">constexpr double pi</div><div class="ttdoc">Pi.</div><div class="ttdef"><b>Definition:</b> Constants.hpp:44</div></div>
<div class="ttc" id="anamespacenc_html"><div class="ttname"><a href="namespacenc.html">nc</a></div><div class="ttdef"><b>Definition:</b> Coordinate.hpp:45</div></div>
<div class="ttc" id="asqr_8hpp_html"><div class="ttname"><a href="sqr_8hpp.html">sqr.hpp</a></div></div>
<div class="ttc" id="anamespacenc_1_1utils_html_ae792e10a24b7e5b8291a6c31a28a4512"><div class="ttname"><a href="namespacenc_1_1utils.html#ae792e10a24b7e5b8291a6c31a28a4512">nc::utils::sqr</a></div><div class="ttdeci">constexpr dtype sqr(dtype inValue) noexcept</div><div class="ttdef"><b>Definition:</b> sqr.hpp:45</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html">nc::integrate::LegendrePolynomial</a></div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:51</div></div>
<div class="ttc" id="a_types_8hpp_html"><div class="ttname"><a href="_types_8hpp.html">Types.hpp</a></div></div>
<div class="ttc" id="anamespacenc_1_1random_html_a00229c23da25284daf436c0a338ea25c"><div class="ttname"><a href="namespacenc_1_1random.html#a00229c23da25284daf436c0a338ea25c">nc::random::f</a></div><div class="ttdeci">dtype f(dtype inDofN, dtype inDofD)</div><div class="ttdef"><b>Definition:</b> f.hpp:58</div></div>
<div class="ttc" id="aclassnc_1_1integrate_1_1_legendre_polynomial_html_ac2d8f6377f8ae7cf27b4d0599eb7880b"><div class="ttname"><a href="classnc_1_1integrate_1_1_legendre_polynomial.html#ac2d8f6377f8ae7cf27b4d0599eb7880b">nc::integrate::LegendrePolynomial::getRoot</a></div><div class="ttdeci">const std::vector&lt; double &gt; &amp; getRoot() const noexcept</div><div class="ttdef"><b>Definition:</b> gauss_legendre.hpp:85</div></div>
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_34171bd951b13a53aa9f237277a18e40.html">NumCpp</a></li><li class="navelem"><a class="el" href="dir_10b69f38d52e59bd23d9fc1937bea22a.html">Integrate</a></li><li class="navelem"><a class="el" href="gauss__legendre_8hpp.html">gauss_legendre.hpp</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
  </ul>
</div>
</body>
</html>
